using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.Diagnostics;
using System.IO;

namespace worktime
{
	public partial class FormAbout : Form
	{
		public FormAbout()
		{
			InitializeComponent();

            int major = Program.Version / 100;
            int minor = Program.Version % 100;

			lblVersion.Text = string.Format("v{0}.{1}", major, minor);
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			Close();
		}

		delegate void SetControlValueCallback(Control oControl, string propName, object propValue);
		private void SetControlPropertyValue(Control oControl, string propName, object propValue)
		{
			if (oControl.InvokeRequired)
			{
				SetControlValueCallback d = new SetControlValueCallback(SetControlPropertyValue);
				oControl.Invoke(d, new object[] { oControl, propName, propValue });
				return;
			}
			Type t = oControl.GetType();
			PropertyInfo[] props = t.GetProperties();
			foreach (PropertyInfo p in props)
			{
				if (p.Name.ToUpper() == propName.ToUpper())
				{
					p.SetValue(oControl, propValue, null);
				}
			}
		}

        private void labelIcon_DoubleClick(object sender, EventArgs e)
        {
            Close();

            Process p = new Process();
            p.StartInfo.FileName = "Explorer";
            string pathToDatabase = Path.Combine(Path.GetDirectoryName(Program.DatabaseFullFileName), Program.DatabaseFileName);
            p.StartInfo.Arguments = string.Format("/Select, \"{0}\"", pathToDatabase);
            p.Start();
        }	
	}
}